<script setup lang="ts">
import type { ConsultOrderItem } from "@/types/chitchat";
import { OrderType } from "@/enum";
import DetailButton from "@/components/lib/DetailButton.vue";

const props = defineProps<{
    item: ConsultOrderItem
}>();


const emits = defineEmits<{
    (eventName: "delete", id: string): void
}>();


const handleDelete = (id: string) => {
    emits("delete", id);
};

</script>

<template>
    <div class="consult-item">
        <div class="head van-hairline--bottom">
            <img class="img" src="@/assets/images/avatar-doctor.svg" />
            <p>{{ item.docInfo?.name || "暂未分配医生" }}</p>
            <span :class="{ orange: item.status === OrderType.ConsultPay,green: item.status === OrderType.ConsultChat}"
            >{{ item.statusValue }}</span
            >
        </div>
        <div class="body" @click="$router.push(`/consultDetail/${item.id}`)">
            <div class="body-row">
                <div class="body-label">患者</div>
                <div class="body-value">{{ item.patientInfo.name }}</div>
            </div>
            <div class="body-row">
                <div class="body-label">病情描述</div>
                <div class="body-value">{{ item.illnessDesc }}</div>
            </div>
            <div class="body-row">
                <div class="body-label">价格</div>
                <div class="body-value">¥ {{ item.payment.toFixed(2) }}</div>
            </div>
            <div class="body-row">
                <div class="body-label">创建时间</div>
                <div class="body-value tip">{{ item.createTime }}</div>
            </div>
        </div>
        <detail-button :item="item" @delete="handleDelete"></detail-button>
    </div>
</template>

<style scoped lang="scss">
.consult-item {
    border-radius: 4px;
    box-shadow: 0px 0px 22px 0px rgba(245, 245, 245, 0.1);
    background-color: #fff;
    margin-bottom: 10px;

    .head {
        display: flex;
        align-items: center;
        height: 50px;
        padding: 0 15px;

        .img {
            width: 20px;
            height: 20px;
        }

        > p {
            flex: 1;
            font-size: 15px;
            padding-left: 10px;
        }

        > span {
            color: var(--cp-tag);

            &.orange {
                color: #f2994a;
            }

            &.green {
                color: var(--cp-primary);
            }
        }
    }

    .body {
        padding: 15px 15px 8px 15px;

        .body-row {
            display: flex;
            margin-bottom: 7px;
        }

        .body-label {
            width: 62px;
            font-size: 13px;
            color: var(--cp-tip);
        }

        .body-value {
            width: 250px;

            &.tip {
                color: var(--cp-tip);
            }
        }
    }

}
</style>
